package com.example.train_operate.controller;

import com.example.train_operate.entity.Electric;
import com.example.train_operate.service.ElectricService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "电源设备检修任务接口")
@RequestMapping("/electric")
public class ElectricController {

    @Resource
    private ElectricService electricService;

    /**
     * 添加电源设备检修任务
     * @param electric
     * @return
     */
    @PostMapping("/addElectric")
    @ApiOperation("添加电源设备检修任务")
    public Result addElectric(@RequestBody Electric electric){
        return electricService.addElectric(electric);
    }

    /**
     * 根据id查询电源设备检修任务
     * @param electricId
     * @return
     */
    @GetMapping("/getElectricById/{electricId}")
    @ApiOperation("根据id查询电源设备检修任务")
    public Result getElectricById(@PathVariable Integer electricId){
        return electricService.getElectricById(electricId);
    }

    /**
     * 修改电源设备检修任务
     * @param electric
     * @return
     */
    @PutMapping("/updateElectric")
    @ApiOperation("修改电源设备检修任务")
    public Result updateElectric(@RequestBody Electric electric){
        return electricService.updateElectric(electric);
    }
}
